-
-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix: correct esm configuration for loadable/server, fixes: #999 * chore: put common-js override in * update snapshots
- Loading branch information
Showing
11 changed files
with
98 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,13 @@ | |
"name": "@loadable/component", | ||
"description": "React code splitting made easy.", | ||
"version": "5.16.3", | ||
"main": "./dist/loadable.cjs.js", | ||
"module": "./dist/loadable.esm.mjs", | ||
"main": "./dist/cjs/loadable.cjs.js", | ||
"module": "./dist/esm/loadable.esm.mjs", | ||
"exports": { | ||
".": { | ||
"require": "./dist/loadable.cjs.js", | ||
"import": "./dist/loadable.esm.mjs", | ||
"default": "./dist/loadable.cjs.js" | ||
"require": "./dist/cjs/loadable.cjs.js", | ||
"import": "./dist/esm/loadable.esm.mjs", | ||
"default": "./dist/cjs/loadable.cjs.js" | ||
} | ||
}, | ||
"repository": "[email protected]:gregberge/loadable-components.git", | ||
|
@@ -37,7 +37,8 @@ | |
"license": "MIT", | ||
"scripts": { | ||
"prebuild": "shx rm -rf dist", | ||
"build": "cross-env rollup -c", | ||
"build": "cross-env rollup -c && yarn create-cjs-package-json", | ||
"create-cjs-package-json": "echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json", | ||
"prepublishOnly": "yarn run build" | ||
}, | ||
"peerDependencies": { | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"dist/cjs/loadable-server.cjs.js": { | ||
"bundled": 18664, | ||
"minified": 10144, | ||
"gzipped": 2837 | ||
}, | ||
"dist/esm/loadable-server.esm.mjs": { | ||
"bundled": 18299, | ||
"minified": 9859, | ||
"gzipped": 2766, | ||
"treeshaked": { | ||
"rollup": { | ||
"code": 279, | ||
"import_statements": 235 | ||
}, | ||
"webpack": { | ||
"code": 13218 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,13 @@ | |
"description": "Server utilities for loadable.", | ||
"version": "5.16.2", | ||
"type": "module", | ||
"main": "./lib/cjs/index.js", | ||
"module": "./lib/esm/index.js", | ||
"main": "./dist/cjs/loadable-server.cjs.js", | ||
"module": "./dist/esm/loadable-server.esm.mjs", | ||
"exports": { | ||
".": { | ||
"require": "./lib/cjs/index.js", | ||
"import": "./lib/esm/index.js", | ||
"default": "./lib/cjs/index.js" | ||
"require": "./dist/cjs/loadable-server.cjs.js", | ||
"import": "./dist/esm/loadable-server.esm.mjs", | ||
"default": "./dist/cjs/loadable-server.cjs.js" | ||
} | ||
}, | ||
"repository": "[email protected]:gregberge/loadable-components.git", | ||
|
@@ -29,12 +29,9 @@ | |
}, | ||
"license": "MIT", | ||
"scripts": { | ||
"prebuild": "shx rm -rf lib", | ||
"build:esm": "MODULE_TARGET=esm yarn run build:script -d lib/esm", | ||
"build:cjs": "MODULE_TARGET=cjs yarn run build:script -d lib/cjs && yarn run create-cjs-package-json", | ||
"build:script": "BUILD_TARGET=node babel --config-file ../../babel.config.js --ignore \"**/*.test.js\" src", | ||
"build": "yarn build:esm && yarn build:cjs", | ||
"create-cjs-package-json": "echo '{\"type\": \"commonjs\"}' > ./lib/cjs/package.json", | ||
"prebuild": "shx rm -rf dist", | ||
"build": "cross-env rollup -c && yarn create-cjs-package-json", | ||
"create-cjs-package-json": "echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json", | ||
"prepublishOnly": "yarn run build", | ||
"update-fixtures": "yarn --cwd ../../examples/__fixtures__ build:webpack && rm -rf ./__fixtures__ && cp -R ../../examples/__fixtures__/target ./__fixtures__ " | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import nodeResolve from 'rollup-plugin-node-resolve' | ||
import babel from 'rollup-plugin-babel' | ||
import replace from 'rollup-plugin-replace' | ||
import commonjs from 'rollup-plugin-commonjs' | ||
import { terser } from 'rollup-plugin-terser' | ||
import { sizeSnapshot } from 'rollup-plugin-size-snapshot' | ||
import pkg from './package.json' | ||
|
||
const input = 'src/index.js' | ||
const name = 'loadable' | ||
const globals = { | ||
react: 'React', | ||
'hoist-non-react-statics': 'hoistNonReactStatics', | ||
} | ||
|
||
const external = id => !id.startsWith('.') && !id.startsWith('/') | ||
|
||
const getBabelOptions = ({ useESModules }) => ({ | ||
exclude: '**/node_modules/**', | ||
runtimeHelpers: true, | ||
presets: [ | ||
['@babel/preset-env', { loose: true }], | ||
['@babel/preset-react', { useBuiltIns: true }], | ||
], | ||
plugins: [ | ||
'@babel/plugin-proposal-class-properties', | ||
'babel-plugin-annotate-pure-calls', | ||
['@babel/plugin-transform-runtime', { useESModules }], | ||
], | ||
}) | ||
|
||
export default [ | ||
// cjs | ||
{ | ||
input, | ||
output: { file: pkg.main, format: 'cjs', exports: 'named' }, | ||
external, | ||
plugins: [babel(getBabelOptions({ useESModules: false })), sizeSnapshot()], | ||
}, | ||
// esm | ||
{ | ||
input, | ||
output: { file: pkg.module, format: 'esm' }, | ||
external, | ||
plugins: [babel(getBabelOptions({ useESModules: true })), sizeSnapshot()], | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { default as ChunkExtractorManager } from './ChunkExtractorManager.js' | ||
export { default as ChunkExtractor } from './ChunkExtractor.js' | ||
export { default as ChunkExtractorManager } from './ChunkExtractorManager' | ||
export { default as ChunkExtractor } from './ChunkExtractor' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters