Skip to content

Commit

Permalink
[BUGFIX] rollup step should deactivate ember modules polyfill >= 3.27 (
Browse files Browse the repository at this point in the history
…#7527)

* disable modules polyfills when transpiling for rollup

* implement fix

* fix lint

* fix expansion

* better comment
  • Loading branch information
runspired authored May 19, 2021
1 parent 5cf97b7 commit c67237b
Show file tree
Hide file tree
Showing 22 changed files with 123 additions and 41 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"debug": "^4.1.1",
"ember-cli": "~3.26.1",
"ember-cli-app-version": "^5.0.0",
"ember-cli-babel": "^7.26.3",
"ember-cli-babel": "^7.26.6",
"ember-cli-blueprint-test-helpers": "^0.19.1",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-htmlbars": "^5.1.2",
Expand Down
1 change: 1 addition & 0 deletions packages/-ember-data/ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = function (defaults) {
},
'ember-cli-babel': {
throwUnlessParallelizable: true,
includeExternalHelpers: true,
},
'ember-cli-terser': {
exclude: ['assets/dummy.js', 'assets/tests.js', 'assets/test-support.js', 'dist/docs/*', 'docs/*'],
Expand Down
4 changes: 2 additions & 2 deletions packages/-ember-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@ember/string": "^1.0.0",
"@glimmer/env": "^0.1.7",
"broccoli-merge-trees": "^4.2.0",
"ember-cli-babel": "^7.26.3",
"ember-cli-babel": "^7.26.6",
"ember-cli-typescript": "^4.1.0",
"ember-inflector": "^4.0.1"
},
Expand Down Expand Up @@ -98,4 +98,4 @@
"node": "12.16.2",
"yarn": "1.22.4"
}
}
}
4 changes: 2 additions & 2 deletions packages/adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@ember-data/store": "3.29.0-alpha.3",
"@ember/edition-utils": "^1.2.0",
"@ember/string": "^1.0.0",
"ember-cli-babel": "^7.26.3",
"ember-cli-babel": "^7.26.6",
"ember-cli-test-info": "^1.0.0",
"ember-cli-typescript": "^4.1.0"
},
Expand Down Expand Up @@ -59,4 +59,4 @@
"node": "12.16.2",
"yarn": "1.22.4"
}
}
}
4 changes: 2 additions & 2 deletions packages/canary-features/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"scripts": {},
"dependencies": {
"ember-cli-babel": "^7.26.3",
"ember-cli-babel": "^7.26.6",
"ember-cli-typescript": "^4.1.0"
},
"devDependencies": {
Expand Down Expand Up @@ -45,4 +45,4 @@
"node": "12.16.2",
"yarn": "1.22.4"
}
}
}
4 changes: 2 additions & 2 deletions packages/debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@ember-data/private-build-infra": "3.29.0-alpha.3",
"@ember/edition-utils": "^1.2.0",
"@ember/string": "^1.0.0",
"ember-cli-babel": "^7.26.3",
"ember-cli-babel": "^7.26.6",
"ember-cli-test-info": "^1.0.0",
"ember-cli-typescript": "^4.1.0"
},
Expand Down Expand Up @@ -57,4 +57,4 @@
"node": "12.16.2",
"yarn": "1.22.4"
}
}
}
4 changes: 2 additions & 2 deletions packages/model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@ember/edition-utils": "^1.2.0",
"@ember/string": "^1.0.0",
"ember-cache-primitive-polyfill": "^1.0.1",
"ember-cli-babel": "^7.26.3",
"ember-cli-babel": "^7.26.6",
"ember-cli-string-utils": "^1.1.0",
"ember-cli-test-info": "^1.0.0",
"ember-cli-typescript": "^4.1.0",
Expand Down Expand Up @@ -64,4 +64,4 @@
"node": "12.16.2",
"yarn": "1.22.4"
}
}
}
4 changes: 2 additions & 2 deletions packages/private-build-infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"broccoli-rollup": "^4.1.1",
"calculate-cache-key-for-tree": "^2.0.0",
"chalk": "^4.0.0",
"ember-cli-babel": "^7.26.3",
"ember-cli-babel": "^7.26.6",
"ember-cli-path-utils": "^1.0.0",
"ember-cli-string-utils": "^1.1.0",
"ember-cli-typescript": "^4.1.0",
Expand All @@ -48,4 +48,4 @@
"node": "12.16.2",
"yarn": "1.22.4"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const calculateCacheKeyForTree = require('calculate-cache-key-for-tree');
const Funnel = require('broccoli-funnel');
const merge = require('broccoli-merge-trees');
const BroccoliDebug = require('broccoli-debug');
const VersionChecker = require('ember-cli-version-checker');

const rollupPrivateModule = require('./utilities/rollup-private-module');

Expand Down Expand Up @@ -159,6 +160,8 @@ function addonBuildConfigForDataPackage(PackageName) {
let babel = this.addons.find((addon) => addon.name === 'ember-cli-babel');
let externalDeps = this.externalDependenciesForPrivateModule();

const host = this._findHost();

// don't print this for consumers
if (this.isDevelopingAddon()) {
// eslint-disable-next-line no-console
Expand All @@ -168,11 +171,15 @@ function addonBuildConfigForDataPackage(PackageName) {
)}']`
);
}
let checker = new VersionChecker(this.project);
let emberVersion = checker.for('ember-source');

let privateTree = rollupPrivateModule(tree, {
packageName: PackageName,
babelCompiler: babel,
babelOptions: this.options.babel,
emberVersion: emberVersion,
emberCliBabelOptions: host.options && host.options['ember-cli-babel'] ? host.options['ember-cli-babel'] : {},
onWarn: this._suppressUneededRollupWarnings.bind(this),
externalDependencies: this.externalDependenciesForPrivateModule(),
destDir: this.getOutputDirForVersion(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,53 @@ module.exports = function rollupPrivateModule(tree, options) {
destDir: '-private',
});

const emberCliBabelOptions = {
// we leave our output as valid ES
// for the consuming app's config to transpile as desired
// so we don't want to compileModules to amd here
compileModules: false,

// we never need this on our own stuff
disableEmberDataPackagesPolyfill: true,

// TODO for the embroider world we want to leave our -private module
// as an es module and only transpile the few things we genuinely care about.
// ideally this would occur as a pre-publish step so that consuming apps would
// just see a `-private.js` file and not pay any additional costs.
// CURRENTLY we transpile the -private module fully acccording to the
// consuming app's config, so we must leave these enabled.
disablePresetEnv: false,
disableDebugTooling: false,
disableDecoratorTransforms: false,

throwUnlessParallelizable: true,

// consuming app will take care of this if needed,
// we don't need to also include
includePolyfill: false,

// defer to consuming app's selection
// necessary as only consuming app can set this, must only have
// one copy
includeExternalHelpers: options.emberCliBabelOptions.includeExternalHelpers || false,

extensions: ['js', 'ts'],
};

// and we don't want
// to convert imports to globals when real modules is possible
// this is necessary because compileModules: false forces globals
// conversion without it.
if (options.emberVersion.gte('3.27.0')) {
// TODO should we just set this all the time?
// yes, this needs to be "false" to disable it in 3.27+
// when compileModules is false (which it is)
emberCliBabelOptions.disableEmberModulesAPIPolyfill = false;
}

let privateTree = babelCompiler.transpileTree(debugTree(withPrivate, 'babel-private:input'), {
babel: babelOptions,
'ember-cli-babel': {
compileModules: false,
extensions: ['js', 'ts'],
},
'ember-cli-babel': emberCliBabelOptions,
});

privateTree = debugTree(privateTree, 'babel-private:output');
Expand All @@ -27,7 +68,7 @@ module.exports = function rollupPrivateModule(tree, options) {
output: [
{
file: `${packageName}/-private.js`,
format: babelCompiler.shouldCompileModules() ? 'amd' : 'es',

This comment has been minimized.

Copy link
@stefanpenner

stefanpenner Aug 26, 2021

Member

Why was this removed? Without this ember-data no longer respects the shouldCompileModules option, breaking embroider (context: embroider-build/embroider#946)

This comment has been minimized.

Copy link
@stefanpenner

stefanpenner Aug 26, 2021

Member
format: 'amd',
amd: { id: `${packageName}/-private` },
exports: 'named',
},
Expand Down
4 changes: 2 additions & 2 deletions packages/record-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@ember-data/private-build-infra": "3.29.0-alpha.3",
"@ember-data/store": "3.29.0-alpha.3",
"@ember/edition-utils": "^1.2.0",
"ember-cli-babel": "^7.26.3",
"ember-cli-babel": "^7.26.6",
"ember-cli-test-info": "^1.0.0",
"ember-cli-typescript": "^4.1.0"
},
Expand Down Expand Up @@ -70,4 +70,4 @@
"node": "12.16.2",
"yarn": "1.22.4"
}
}
}
4 changes: 2 additions & 2 deletions packages/serializer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"dependencies": {
"@ember-data/private-build-infra": "3.29.0-alpha.3",
"@ember-data/store": "3.29.0-alpha.3",
"ember-cli-babel": "^7.26.3",
"ember-cli-babel": "^7.26.6",
"ember-cli-test-info": "^1.0.0",
"ember-cli-typescript": "^4.1.0"
},
Expand Down Expand Up @@ -58,4 +58,4 @@
"node": "12.16.2",
"yarn": "1.22.4"
}
}
}
4 changes: 2 additions & 2 deletions packages/store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@ember-data/private-build-infra": "3.29.0-alpha.3",
"@ember/string": "^1.0.0",
"@glimmer/tracking": "^1.0.4",
"ember-cli-babel": "^7.26.3",
"ember-cli-babel": "^7.26.6",
"ember-cli-path-utils": "^1.0.0",
"ember-cli-typescript": "^4.1.0"
},
Expand Down Expand Up @@ -58,4 +58,4 @@
"node": "12.16.2",
"yarn": "1.22.4"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"broccoli-asset-rev": "^3.0.0",
"ember-cli": "~3.26.1",
"ember-cli-app-version": "^5.0.0",
"ember-cli-babel": "^7.26.3",
"ember-cli-babel": "^7.26.6",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-htmlbars": "^5.1.2",
"ember-cli-inject-live-reload": "^2.0.2",
Expand All @@ -55,4 +55,4 @@
"node": "12.16.2",
"yarn": "1.22.4"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"broccoli-asset-rev": "^3.0.0",
"ember-cli": "~3.26.1",
"ember-cli-app-version": "^5.0.0",
"ember-cli-babel": "^7.26.3",
"ember-cli-babel": "^7.26.6",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-htmlbars": "^5.1.2",
"ember-cli-inject-live-reload": "^2.0.2",
Expand All @@ -54,4 +54,4 @@
"node": "12.16.2",
"yarn": "1.22.4"
}
}
}
4 changes: 2 additions & 2 deletions packages/unpublished-fastboot-test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"broccoli-asset-rev": "^3.0.0",
"ember-cli": "~3.26.1",
"ember-cli-app-version": "^5.0.0",
"ember-cli-babel": "^7.26.3",
"ember-cli-babel": "^7.26.6",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-fastboot": "^2.2.1",
"ember-cli-fastboot-testing": "^0.2.3",
Expand Down Expand Up @@ -70,4 +70,4 @@
"node": "12.16.2",
"yarn": "1.22.4"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"broccoli-asset-rev": "^3.0.0",
"ember-cli": "~3.26.1",
"ember-cli-app-version": "^5.0.0",
"ember-cli-babel": "^7.26.3",
"ember-cli-babel": "^7.26.6",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-htmlbars": "^5.1.2",
"ember-cli-inject-live-reload": "^2.0.2",
Expand All @@ -55,4 +55,4 @@
"node": "12.16.2",
"yarn": "1.22.4"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"broccoli-asset-rev": "^3.0.0",
"ember-cli": "~3.26.1",
"ember-cli-app-version": "^5.0.0",
"ember-cli-babel": "^7.26.3",
"ember-cli-babel": "^7.26.6",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-htmlbars": "^5.1.2",
"ember-cli-inject-live-reload": "^2.0.2",
Expand All @@ -55,4 +55,4 @@
"node": "12.16.2",
"yarn": "1.22.4"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"broccoli-asset-rev": "^3.0.0",
"ember-cli": "~3.26.1",
"ember-cli-app-version": "^5.0.0",
"ember-cli-babel": "^7.26.3",
"ember-cli-babel": "^7.26.6",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-htmlbars": "^5.1.2",
"ember-cli-inject-live-reload": "^2.0.2",
Expand All @@ -53,4 +53,4 @@
"node": "12.16.2",
"yarn": "1.22.4"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"broccoli-asset-rev": "^3.0.0",
"ember-cli": "~3.26.1",
"ember-cli-app-version": "^5.0.0",
"ember-cli-babel": "^7.26.3",
"ember-cli-babel": "^7.26.6",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-htmlbars": "^5.1.2",
"ember-cli-inject-live-reload": "^2.0.2",
Expand All @@ -54,4 +54,4 @@
"node": "12.16.2",
"yarn": "1.22.4"
}
}
}
4 changes: 2 additions & 2 deletions packages/unpublished-test-infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dependencies": {
"@ember-data/private-build-infra": "3.29.0-alpha.3",
"@ember/edition-utils": "^1.2.0",
"ember-cli-babel": "^7.26.3",
"ember-cli-babel": "^7.26.6",
"ember-cli-blueprint-test-helpers": "^0.19.2",
"ember-cli-typescript": "^4.1.0",
"ember-get-config": "^0.2.4",
Expand Down Expand Up @@ -55,4 +55,4 @@
"node": "12.16.2",
"yarn": "1.22.4"
}
}
}
Loading

0 comments on commit c67237b

Please sign in to comment.